home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / eulisp / mpfeel.lha / MPFeel / Plurals / MP_Context.h < prev    next >
C/C++ Source or Header  |  1992-07-05  |  3KB  |  84 lines

  1. /*
  2.  *    Plurals
  3.  *
  4.  *    Author:    S.C.Merrall
  5.  *
  6.  *    File:    MP_Context.h
  7.  *
  8.  *    Contents:    Object functions Start, Length and Offset
  9.  *                      The Lisplural structure
  10.  *
  11.  *    Description:    These are handles on a plural context. From this we
  12.  *            find which processors are supposed to be active
  13.  *            before we start operating with a plural.
  14.  *
  15.  *    Change History:
  16.  *
  17.  *    Date   Name Comment
  18.  *    -------- ---- -------
  19.  *    28:06:91 SCM  Created - modified from MP_Plural.h
  20.  *    20:01:91 SCM  onverted to work with proc_pair.h
  21.  *    08:04:92 SCM  Modifications for GC - handles are chained.
  22.  *    07:06:92 SCM  Added rectangle orientated macros
  23.  *
  24.  */
  25.  
  26. typedef unsigned short natural;
  27.  
  28. struct MP_Context { 
  29.   OD_COMMON_STRUCTURE;
  30.   object  next;
  31.   natural offset;
  32.   natural width;
  33.   natural height;
  34.   natural br_x;
  35.   natural br_y;
  36. };
  37.  
  38. extern struct MP_Context OC_MP_Context;
  39.  
  40. #ifdef OD_OBJECT_CHECK
  41.  
  42. #define OA_width(OBJECT) (error(OBJECT,"OA_width",OI_MP_Context)->MP_Context.width)
  43. #define OA_height(OBJECT) (error(OBJECT,"OA_height",OI_MP_Context)->MP_Context.height)
  44. #define OA_br_x(OBJECT) (error(OBJECT,"OA_br_x",OI_MP_Context)->MP_Context.br_x)
  45. #define OA_br_y(OBJECT) (error(OBJECT,"OA_br_y",OI_MP_Context)->MP_Context.br_y)
  46. #define OA_offset(OBJECT) (error(OBJECT,"OA_offset",OI_MP_Context)->MP_Context.offset)
  47. #define OA_next(OBJECT) (error(OBJECT,"OA_offset",OI_MP_Context)->MP_Context.next)
  48.  
  49. #else
  50.  
  51. #define OA_width(OBJECT) (OBJECT->MP_Context.width)
  52. #define OA_height(OBJECT) (OBJECT->MP_Context.height)
  53. #define OA_br_x(OBJECT) (OBJECT->MP_Context.br_x)
  54. #define OA_br_y(OBJECT) (OBJECT->MP_Context.br_y)
  55. #define OA_offset(OBJECT) (OBJECT->MP_Context.offset)
  56. #define OA_next(OBJECT) (OBJECT->MP_Context.next)
  57.  
  58. #endif
  59.  
  60. /*  These structures have to be garbage collected - to avoid introducing
  61.  *  another flag I am using the one inside the Generic info slot. This means
  62.  *  we can't wrap error around the operation otherwise it will fail if
  63.  *  the structure is already free.
  64.  */
  65.  
  66. #define OM_not_free(OBJECT) (OBJECT->Generic.info)=(OBJECT->Generic.info&(OD_TYPE_MASK))
  67.  
  68. /*  macro expands to conditional statement to execute code on a Contexts set
  69.  *  of processors
  70.  */
  71.  
  72. #define OM_with_context(o) if ((PP_ixproc >= ((1+ OA_br_x(o)) - OA_width(o))) && \
  73.                    (PP_ixproc <= OA_br_x(o)) && \
  74.                    (PP_iyproc >= ((1+ OA_br_y(o)) - OA_height(o))) && \
  75.                    (PP_iyproc <= OA_br_y(o)))
  76.  
  77. #define OM_last(o)  ((OA_br_y(o)*PP_nxproc)+OA_br_x(o))
  78. #define OM_first(o) (((OA_br_y(o)-OA_height(o))*PP_nxproc)+OA_br_x(o)-OA_width(o)+PP_nxproc+1)
  79.  
  80. #define OM_bottom_edge(o) (OA_br_y(o)==PP_iyproc)
  81. #define OM_right_edge(o)  (OA_br_x(o)==PP_ixproc)
  82. #define OM_top_edge(o) (((1+OA_br_y(o)) - OA_height(o))==PP_iyproc)
  83. #define OM_left_edge(o) (((1+OA_br_x(o)) - OA_width(o))==PP_ixproc)
  84.